import React from 'react';
import { Provider } from 'react-redux';
import { store } from './store/reducer/Index';
import AppRouter from './component/AppRouter';
import LandReducer from './store/reducer/LandReducer';
import { withReducers } from './store/StoreUtil';
import {ConfigProvider} from 'antd';
import LandService from './services/LandService';
import { IntlProvider } from 'react-intl';
import './css/main.less';

//初始化组件 app
const App = (props) => {
    const {land, otherName} = props;
    return (
        // ant框架内部多语言
        <ConfigProvider locale={LandService.getAntMessages(land)}>
            <IntlProvider
                locale={otherName}
                key={otherName}
                messages={LandService.getMessages(land)}
            >
                <AppRouter />
            </IntlProvider>
        </ConfigProvider>
    );
}

// 组件中注入reducer
let CApp = withReducers(App, LandReducer);

//组件注入store
const StoreRoot = () => {
    return (
        <Provider store = {store}>
            <CApp />
            {/* <AppRouter /> */}
        </Provider>
    );
}

export default StoreRoot;